//
//  LCPublicGlobel.h
//  lotusCustomer
//
//  Created by 裘依琳 on 2021/3/24.
//

#ifndef LCPublicGlobel_h
#define LCPublicGlobel_h

#import "LCGlobelConst.h"

#define is_iPhoneX ({\
int tmp = 0;\
if (@available(iOS 11.0, *)) {\
if ([UIApplication sharedApplication].delegate.window.safeAreaInsets.top > 20) {\
tmp = 1;\
}else{\
tmp = 0;\
}\
}else{\
tmp = 0;\
}\
tmp;\
})

/// 导航高度
#define LCNavHeight (is_iPhoneX ? 88.f : 64.f)
/// tabBar高度
#define LCTarHeight (is_iPhoneX ? (49.f+34.f) : 49.f)
/// 屏幕高度
#define LCDeviceHeight [UIScreen mainScreen].bounds.size.height
/// 屏幕宽度
#define LCDeviceWidth [UIScreen mainScreen].bounds.size.width
/// 屏幕适配
#define LCDeviceWidthScale [UIScreen mainScreen].bounds.size.width/375

/// 十六进制颜色
#define LCHEXCOLOR(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


/// 黑暗适配  <注意点：控件如果不设置颜色会自动跟随系统白/黑模式走>
UIKIT_STATIC_INLINE UIColor* themeBackgroundColor(UIColor* colorA,UIColor* colorB) {
    ///主题色
//    UIColor *whiteColor = [SkinManage sharedInstance].themeColor;
    UIColor *whiteColor = [UIColor whiteColor];
    // 0代表背景自然色  1代表背景白色 2代表背景黑色
    NSInteger switchType = [[NSUserDefaults standardUserDefaults] integerForKey:LCThemeColorSwitch];
    if (@available(iOS 13.0, *)) {
        whiteColor =[UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) {
            if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) {
                if (switchType == 1) {
                    return colorA;
                } else {
                    return colorB;
                }
            } else {
                if (switchType == 2) {
                    return colorB;
                } else {
                    return colorA;
                }
            }
        }];
    } else {
        if (switchType == 2) {
            return colorB;
        } else {
            return colorA;
        }
    }
    return whiteColor;
}

#endif /* LCPublicGlobel_h */
